package io.github.rascaler.dcenter.db;

import io.github.rascaler.dcenter.properties.BinanceProperties;
import io.github.rascaler.dcenter.properties.MemoryDBProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @ClassName DbManager
 * @Description TODO
 * @Author wurenqing
 * @Date 2023-11-24 16:43
 */

@Component
public class DbManager {
    @Autowired
    private BinanceProperties binanceProperties;

    private MemoryDB mdb;

    // 0=未初始化，1=正在初始化，2=初始化完成
    private int state;

    public MemoryDB getMdb() {
        return mdb;
    }


    public Integer getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    @PostConstruct
    public void init() {
        mdb = new MemoryDB(new MemoryDB.SaveConfig(binanceProperties.getSaveConfigInterval(), binanceProperties.getMemorydbPath()));
    }


}